package com.authine.cloudpivot.ext.dto.kingDee.request;

import com.authine.cloudpivot.ext.utils.kingdee.DateUtils;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;
import java.util.List;


@Data
@JsonInclude(value= JsonInclude.Include.NON_NULL)
@Schema(description = "ModelEntity")
public class ModelEntity {

    //--基础数据部分--
    /**
     * 客户、供应商、部门、银行 编码 、银行账号
     */
    @JsonProperty("FNumber")
    @Schema(description = "客户、供应商、部门、银行 编码 、银行账号")
    private String fNumber;

    /**
     * 客户、供应商、员工、部门、银行 名称 、 账号名称
     */
    @JsonProperty("FName")
    @Schema(description = "客户、供应商、员工、部门、银行 名称 、 账号名称")
    private String fName;

    /**
     * 创建组织
     */
    @JsonProperty("FCreateOrgId")
    @Schema(description = "创建组织")
    private FCreateOrgIdEntity fCreateOrgIdEntity;

    /**
     * 使用组织
     */
    @JsonProperty("FUseOrgId")
    @Schema(description = "使用组织")
    private FUseOrgIdEntity fUseOrgIdEntity;

    /**
     * 员工编码
     */
    @JsonProperty("FStaffNumber")
    @Schema(description = "员工编码")
    private String fStaffNumber;

    /**
     * 上级部门
     */
    @JsonProperty("FParentID")
    @Schema(description = "上级部门")
    private String fParentId;

    /**
     * 部门分组
     */
    @JsonProperty("FGroup")
    @Schema(description = "部门分组")
    private String fGroup;

    /**
     * 开户银行
     */
    @JsonProperty("FBANKID")
    @Schema(description = "开户银行")
    private FBankIdEntity fBankId;


    /**
     * 保存客户供应商
     *
     * @return
     */
    public static ModelEntity addBasic(String cNumber, String uNumber) {
        ModelEntity m = new ModelEntity();
        m.setFCreateOrgIdEntity(FCreateOrgIdEntity.addUser(cNumber));
        m.setFUseOrgIdEntity(FUseOrgIdEntity.addUser(uNumber));
        return m;
    }

    //--业务部分--

    @JsonProperty("FVOUCHERID")
    @Schema(description = "凭证id")
    private Integer fVoucherId;

    @JsonProperty("FAccountBookID")
    @Schema(description = "账号绑定id")
    private FAccountBookIdEntity faccountBookIdEntity;

    @JsonProperty("FDate")
    @Schema(description = "时间")
    private String fDate;

    /**
     * 新增字段2
     */
    @JsonProperty("FBUSDATE")
    @Schema(description = "子时间")
    private String fBusDate;
    /**
     * 新增字段3
     */
    @JsonProperty("FVOUCHERGROUPNO")
    @Schema(description = "凭证组织号")
    private String fVoucherGroupNo;

    /**
     * 新增字段4
     */
    @JsonProperty("FISADJUSTVOUCHER")
    @Schema(description = "fIsAdustVoucher")
    private Boolean fIsAdustVoucher;

    /**
     * 新增字段5
     */
    @JsonProperty("FDocumentStatus")
    @Schema(description = "文档状态")
    private String fDocumentStatus;

    /**
     * 新增字段6
     */
    @JsonProperty("FYEAR")
    @Schema(description = "年限")
    private Integer fYear;

    /**
     * 附件数量
     */
    @JsonProperty("FATTACHMENTS")
    @Schema(description = "附件数量")
    private Integer fAttachments;
    /**
     * 新增字段7 业务类型 手动/自动
     */
    @JsonProperty("FSourceBillKey")
    @Schema(description = "业务类型")
    private FSourceBillKeyEntity fSourceBillKey;

    /**
     * 新增字段8
     */
    @JsonProperty("FPERIOD")
    @Schema(description = "fPeriod")
    private Integer fPeriod;

    @JsonProperty("FVOUCHERGROUPID")
    @Schema(description = "凭证组织")
    private FVoucherGroupIdEntity fVouchergroupid;

    @JsonProperty("FEntity")
    @Schema(description = "金蝶实例集合")
    private List<FEntity> fEntity;


    public static ModelEntity addModel() {
        ModelEntity mo = new ModelEntity();
        mo.setFVoucherId(0);
        mo.setFaccountBookIdEntity(FAccountBookIdEntity.addFavvountBookID());
        mo.setFDate(DateUtils.dateToStr(new Date()));
        mo.setFVouchergroupid(FVoucherGroupIdEntity.addFVOUCHERGROUPID());
        mo.setFAttachments(0);
//        mo.setFBusDate(DateUtils.dateToStr(new Date()));
//        mo.setFVoucherGroupNo("1445");
        mo.setFIsAdustVoucher(false);
//        mo.setFDocumentStatus("Z");
//        mo.setFYear(2019);
        mo.setFSourceBillKey(FSourceBillKeyEntity.addSource());
//        mo.setFPeriod(8);
        return mo;
    }


    public ModelEntity() {
    }

    public ModelEntity(String fNumber, String fName, FCreateOrgIdEntity fCreateOrgIdEntity, FUseOrgIdEntity fUseOrgIdEntity) {
        this.fNumber = fNumber;
        this.fName = fName;
        this.fCreateOrgIdEntity = fCreateOrgIdEntity;
        this.fUseOrgIdEntity = fUseOrgIdEntity;
    }
}
